
#!/bin/bash


function nginx_index(){
cat <<EOF
+-----------------------------------------+
|一键安装nginx脚本
+-----------------------------------------+
EOF
}
nginx_index



if [ ! -d /usr/local/src ];then
   mkdir /usr/local/src
else
   echo "该目录已存在,无需创建"
fi


log_dir=/usr/local/src

function nginx_install()
{
   yum install -y gcc gcc-c++ zlib zlib-devel pcre pcre-devel openssl openssl-devel &>/dev/null
 
   if [ $? -eq 0 ];then
      cd ${log_dir} && \
      wget http://nginx.org/download/nginx-1.14.2.tar.gz &>/dev/null && \
      useradd -M -s /sbin/nologin nginx && \
      tar -xzvf nginx-1.14.2.tar.gz && \
      cd nginx-1.14.2 && \
      ./configure --prefix=/usr/local/nginx \
      --with-http_stub_status_module \
      --with-http_dav_module \
      --with-http_addition_module \
      --with-http_sub_module \
      --with-http_flv_module \
      --with-http_mp4_module \
      --with-pcre \
      --with-http_ssl_module \
      --with-http_gzip_static_module \
      --user=nginx &>/dev/null && \
      make &>/dev/null && make install &>/dev/null
   fi
   
   if [ -e /usr/local/nginx/sbin/nginx ];then
      /usr/local/nginx/sbin/nginx
      echo "Nginx服务安装完成并启动成功!!!"
   fi
}
echo "Nginx服务装备开始安装,请稍等..."
nginx_install









